<%@ tag language="java" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%@ attribute name="id" type="java.lang.String" required="true" description="按钮ID"%>
<%@ attribute name="name" type="java.lang.String" required="true" description="按钮名称"%>
<%@ attribute name="className" type="java.lang.String" required="true" description="按钮css类名"%>
<%@ attribute name="objectId" type="java.lang.String" required="true" description="上传附件或图片对象ID"%>
<%@ attribute name="objectType" type="java.lang.String" required="true" description="上传附件或图片对象类型"%>
<%@ attribute name="callback" type="java.lang.String" required="false" description="上传完图片回调函数"%>
<input id="${id}Id" value="${name}" type="button" class="${className}"/>
<script type="text/javascript">
KindEditor.ready(function(K){
	var uploadbutton = K.uploadbutton({
	    button : K('#${id}Id')[0],
	    fieldName : 'imgFile',
	    url : '${ctx}/image/upload',
	    afterUpload : function(data) {
	    		console.log(data);
	    		<c:if test="${not empty callback}">${callback}</c:if>
	    }
	});
	uploadbutton.fileBox.change(function(e) {
	    uploadbutton.submit();
	});
})
</script>